package com.demo.jwt.controller;

import com.demo.jwt.annotation.LoginRequired;
import com.demo.jwt.annotation.PassToken;
import com.demo.jwt.form.UserForm;
import com.demo.jwt.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    IUserService service;

    @PostMapping("/login")
    @PassToken
    public String login(@RequestBody UserForm userForm) {
        return service.login(userForm);
    }

    @PostMapping("/register")
    @PassToken
    public String register(@RequestBody UserForm userForm) {
        return service.register(userForm);
    }

    @PostMapping("/info")
    @LoginRequired
    public String getInfo() {
        return "你已经通过了验证";
    }
}
